package com.jzsm.common.exception;

import com.jzsm.common.core.domain.AjaxResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理器
 *
 * @author xavier
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    /**
     * 业务异常
     */
    @ExceptionHandler(BusinessException.class)
    public AjaxResult businessException(BusinessException e) {
        return AjaxResult.error(e.getMessage());
    }

    /**
     * 未登录
     */
    @ExceptionHandler(AuthenticationException.class)
    public AjaxResult authException(AuthenticationException e) {
        return AjaxResult.noLogin(e.getMessage());
    }

}
